package com.aaa.vip.controller;

import com.aaa.common.entity.UserBalance;
import com.aaa.common.util.BaseUtil;
import com.aaa.common.util.Result;
import com.aaa.common.vo.Page;
import com.aaa.vip.service.UserBalanceService;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (UserBalance)表控制层
 *
 * @author makejava
 * @since 2025-09-25 19:08:48
 */
@RestController
@RequestMapping("userBalance")
@Log4j2
public class UserBalanceController {
    /**
     * 服务对象
     */
    @Resource
    private UserBalanceService userBalanceService;

    /**
     * 通过TokenID查询单条数据
     *
     * @param
     * @return 实例对象
     */
    @GetMapping("selectMoneyByUserId")
    public Result selectMoneyByUserId() {
        return BaseUtil.success(this.userBalanceService.selectMoneyByUserId());
    }
    @GetMapping("selectMoneyByUserIdUseToken")
    public Result selectMoneyByUserIdUseToken(@RequestParam("userId") Integer userId) {
        return BaseUtil.success(this.userBalanceService.selectMoneyByUserIdUseToken(userId));
    }
    @GetMapping("selectMoneyByUserIdAndStoreId")
    public Result selectMoneyByUserIdAndStoreId(@RequestParam("userId") Integer userId,
                                                @RequestParam("storeId") Integer storeId){
        return BaseUtil.success(this.userBalanceService.selectMoneyByUserIdAndStoreId(userId,storeId));
    }
    /**
     * 分页查询
     *
     * @param page 分页对象
     * @return 查询结果
     */
    @PostMapping("queryByPage")
    public Result queryByPage(@RequestBody Page<UserBalance> page) {
        return BaseUtil.success(this.userBalanceService.queryByPage(page));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("queryById")
    public Result queryById(Integer id) {
        return BaseUtil.success(this.userBalanceService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param userBalance 实体
     * @return 新增结果
     */
    @PostMapping("add")
    public Result add(@RequestBody UserBalance userBalance) {
        return BaseUtil.success(this.userBalanceService.insert(userBalance));
    }

    /**
     * 编辑数据
     *
     * @param userBalance 实体
     * @return 编辑结果
     */
    @PostMapping("edit")
    public Result edit(@RequestBody UserBalance userBalance) {
        return BaseUtil.success(this.userBalanceService.update(userBalance));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping("deleteById")
    public Result deleteById(Integer id) {
        return BaseUtil.success(this.userBalanceService.deleteById(id));
    }

}

